home *** CD-ROM | disk | FTP | other *** search
- Path: wdl1.wdl.loral.com!dst17!mab
- From: mab@dst17.wdl.loral.com (Mark A Biggar)
- Newsgroups: comp.lang.ada,comp.lang.c++
- Subject: Re: some questions re. Ada/GNAT from a C++/GCC user
- Date: 1 Apr 1996 16:17:13 GMT
- Organization: Loral Western Development Labs
- Message-ID: <4jovi9$c2b@wdl1.wdl.loral.com>
- References: <wnewmanDoxrCp.DKv@netcom.com> <Dp1oAw.7Cz@world.std.com> <ROGOFF.96Mar29163036@sccm.Stanford.EDU>
- NNTP-Posting-Host: dst17.wdl.loral.com
-
- In article <ROGOFF.96Mar29163036@sccm.Stanford.EDU> rogoff@sccm.stanford.edu writes:
- > > Why doesn't Ada 95 allow declarations to be interspersed with ordinary
- > > statements as C++ does? (Or does it? _Ada as a Second Language_ is a
- > > big book!) It seems to me that the C++ approach is a small but
- > > definite win. Does it interact very badly somehow with all those
- > > guarantees on elaboration order?
- >
- > To intersperse declarations, you have to use a block_statement, like
- > this:
- >
- > for I in Some_String'Range loop -- I wish I could easily use an iterator here ;-)
- > declare
- > X: constant Character := Some_String(I);
- > begin
- > ...
- > end;
- > end loop;
- >
- > To me, the "declare", "begin", and "end" are just useless verbosity.
- > I prefer the C++ rule.
- >
- >Yes, this seems needlessly verbose. Any Ada guru have a good reason why it has
- >to be this way?
-
- Yeah, 2 reasons. The first goes clear back to the original Ada Strawman
- documnt which calls for a clear distinction between declarations and code
- statements. The second reason is that is also the method of wraping an
- exception handler around soem arbitary piece of code:
-
- for I in Some_String'Range loop
- declare
- X: constant Character := Some_String(I);
- begin
- ...
- exception
- when ... ;
- end;
- end loop;
-
-
- --
- Mark Biggar
- mab@wdl.loral.com
-
-